home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / sticpsrc.lzh / SOURCE.ARC / IP.H < prev    next >
C/C++ Source or Header  |  1989-08-16  |  4KB  |  108 lines

  1. #define    NROUTE    5    /* Number of hash chains in routing table */
  2.  
  3. extern int32 ip_addr;    /* Our IP address for ICMP and source routing */
  4.  
  5. extern char ip_ttl;    /* Default time-to-live for IP datagrams */
  6.  
  7. #define    IPVERSION    4
  8. /* IP header, INTERNAL representation */
  9. struct ip {
  10.     char version;        /* IP version number */
  11.     char tos;        /* Type of service */
  12.     int16 length;        /* Total length */
  13.     int16 id;        /* Identification */
  14.     int16 fl_offs;        /* Flags + fragment offset */
  15.  
  16. #define    F_OFFSET    0x1fff    /* Offset field */
  17. #define    DF    0x4000        /* Don't fragment flag */
  18. #define    MF    0x2000        /* More Fragments flag */    
  19.  
  20.     char ttl;        /* Time to live */
  21.     char protocol;        /* Protocol */
  22.     int32 source;        /* Source address */
  23.     int32 dest;        /* Destination address */
  24.     char options[44];    /* Options field */
  25.     int16 optlen;        /* Length of options field, bytes */
  26. };
  27. #define    NULLIP    (struct ip *)0
  28. #define    IPLEN    20    /* Length of standard IP header */
  29.  
  30. /* Fields in option type byte */
  31. #define    OPT_COPIED    0x80    /* Copied-on-fragmentation flag */
  32. #define    OPT_CLASS    0x60    /* Option class */
  33. #define    OPT_NUMBER    0x1f    /* Option number */
  34.  
  35. /* IP option numbers */
  36. #define    IP_EOL        0    /* End of options list */
  37. #define    IP_NOOP        1    /* No Operation */
  38. #define    IP_SECURITY    2    /* Security parameters */
  39. #define    IP_LSROUTE    3    /* Loose Source Routing */
  40. #define    IP_TIMESTAMP    4    /* Internet Timestamp */
  41. #define    IP_RROUTE    7    /* Record Route */
  42. #define    IP_STREAMID    8    /* Stream ID */
  43. #define    IP_SSROUTE    9    /* Strict Source Routing */
  44.  
  45. /* Timestamp option flags */
  46. #define    TS_ONLY        0    /* Time stamps only */
  47. #define    TS_ADDRESS    1    /* Addresses + Time stamps */
  48. #define    TS_PRESPEC    3    /* Prespecified addresses only */
  49.  
  50. /* IP routing table entry */
  51. struct route {
  52.     struct route *prev;    /* Linked list pointers */
  53.     struct route *next;
  54.     int32 target;        /* Target IP address */
  55.     int32 gateway;        /* IP address of local gateway for this target */
  56.     int metric;        /* Hop count, whatever */
  57.     struct interface *interface;    /* Device interface structure */
  58. };
  59. #define    NULLROUTE    (struct route *)0
  60. extern struct route *routes[33][NROUTE];    /* Routing table */
  61.  
  62. /* Cache for the last-used routing entry, speeds up the common case where
  63.  * we handle a burst of packets to the same destination
  64.  * (actually an array of NROUTE of these is used to cache more than one
  65.  *  destination, to speed up the IP switch actions)
  66.  */
  67. struct rt_cache {
  68.     int32 target;
  69.     struct route *route;
  70. };
  71.  
  72. /* Reassembly descriptor */
  73. struct reasm {
  74.     struct reasm *next;    /* Linked list pointers */
  75.     struct reasm *prev;
  76.     int32 source;        /* These four fields uniquely describe a datagram */
  77.     int32 dest;
  78.     int16 id;
  79.     char protocol;
  80.     int16 length;        /* Entire datagram length, if known */
  81.     struct timer timer;    /* Reassembly timeout timer */
  82.     struct frag *fraglist;    /* Head of data fragment chain */
  83. };
  84. #define    NULLREASM    (struct reasm *)0
  85.  
  86. /* Fragment descriptor in a reassembly list */
  87. struct frag {
  88.     struct frag *prev;    /* Previous fragment on list */
  89.     struct frag *next;    /* Next fragment */
  90.     struct mbuf *buf;    /* Actual fragment data */
  91.     int16 offset;        /* Starting offset of fragment */
  92.     int16 last;        /* Ending offset of fragment */
  93. };
  94. #define    NULLFRAG    (struct frag *)0
  95.  
  96. extern struct reasm *reasmq;    /* The list of reassembly descriptors */
  97.  
  98. /* IP error logging counters */
  99. struct ip_stats {
  100.     long total;        /* Total packets received */
  101.     unsigned runt;        /* Smaller than minimum size */
  102.     unsigned length;    /* IP header length field too small */
  103.     unsigned version;    /* Wrong IP version */
  104.     unsigned checksum;    /* IP header checksum errors */
  105.     unsigned badproto;    /* Unsupported protocol */
  106. };
  107. extern struct ip_stats ip_stats;
  108.